rng(2019)
addpath 'source/lib/Confidence_Bands/1SimInferenceClass'
m = readtable('build/descriptive/data.csv');

all_beta_hats = m.partisan_affect_polarization;
diag_sigma    = m.partisan_affect_polarization_sd;

numdraws_supt = 1000;
signif_level  = .05;
for i = 1:15
    if i == 7
        continue
    end
    temp = unique(m.country);
    c    = temp(i, 1);
    beta_hats = m.partisan_affect_polarization(nominal(m.country) == char(c));
    Sigma_hat = diag(m.partisan_affect_polarization_sd(nominal(m.country) == char(c))).^2;
    bands_plugin = SimInference.bands_plugin(beta_hats', Sigma_hat, [], {'supt'}, numdraws_supt, 1-signif_level);
    writematrix(bands_plugin{1}, sprintf('build/descriptive/sup_t_partisan_affect_polar_%s.csv', char(c)))
end

exit
 